home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / ARITEST.ZIP / DEMOS / ARIELDEM / UNIT1.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-12-22  |  3.7 KB  |  149 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Spin;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     btnStart: TButton;
  12.     lstTimeResults: TListBox;
  13.     Label1: TLabel;
  14.     SpinEdit1: TSpinEdit;
  15.     procedure btnStartClick(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. uses DelDao;
  30.  
  31. procedure TForm1.btnStartClick(Sender: TObject);
  32. var
  33.   MyEng:    TDDdbEngine;
  34.   MyWs:     TDDWorkspace;
  35.   MyDB:     TDDDatabase;
  36.   MyRs:     TDDRecordset;
  37.   Tbl1:     TDDTableDef;
  38.   Fld1:     TDDField;
  39.   Fld2:     TDDField;
  40.   sT1, eT1: integer;
  41.   s, e:     integer;
  42.   i:        integer;
  43. begin
  44.   try
  45.     btnStart.Enabled := false;
  46.  
  47.     try
  48.       MyEng := TDDdbEngine.Create;  //   this is done automatically in VB
  49.  
  50.       //  start timer 1
  51.       sT1 := GetTickCount;
  52.       MyWs := MyEng.Workspaces[0];
  53.  
  54.       // create database
  55.       //  start timer 2
  56.       s := GetTickCount;
  57.       MyDB := MyWs.CreateDatabase('SpeedAriel.MDB', DAOdbLangGeneral, DAOdbVersion30);
  58.       try
  59.         Tbl1 := MyDB.CreateTableDef('Table1', 0, '', '');
  60.         Fld1 := Tbl1.CreateField('IntField', DAOdbLong, 4);
  61.         Fld1.Attributes := DAOdbAutoIncrField;
  62.         Fld2 := Tbl1.CreateField('TextField', DAOdbText, 30);
  63.         Tbl1.Fields.Append(Fld1);
  64.         Tbl1.Fields.Append(Fld2);
  65.         MyDb.TableDefs.Append(Tbl1);
  66.       finally
  67.       if assigned(Fld2) then
  68.         Fld2.Free;
  69.       if assigned(Fld1) then
  70.         Fld1.Free;
  71.       if assigned(Tbl1) then
  72.         Tbl1.Free;
  73.       end;
  74.       e := GetTickCount;
  75.       lstTimeResults.Items.Add('Created SpeedAriel.MDB: ' + IntToStr((e - s) div 1000));
  76.       //  end timer 2
  77.  
  78.       //  fill data
  79.       //  start timer 3
  80.       s := GetTickCount;
  81.       try
  82.         MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
  83.         for i := 1 to SpinEdit1.Value do
  84.         begin
  85.           MyRs.AddNew;
  86.           MyRs.Fields['TextField'].Value := 'Entry #' + IntToStr(i);
  87.           MyRs.Update;
  88.         end;
  89.         MyRs.Close;
  90.       finally
  91.         if assigned(MyRs) then
  92.           MyRs.Free;
  93.       end;
  94.       e := GetTickCount;
  95.       lstTimeResults.Items.Add('Filled SpeedAriel.MDB: ' + IntToStr((e - s) div 1000));
  96.       //  end timer 3
  97.  
  98.       //  forward navigation test
  99.       //  start timer 4
  100.       s := GetTickCount;
  101.       try
  102.         MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
  103.         while not MyRs.EOF do
  104.           MyRs.MoveNext;
  105.         MyRs.Close;
  106.       finally
  107.         if assigned(MyRs) then
  108.           MyRs.Free;
  109.       end;
  110.       e := GetTickCount;
  111.       lstTimeResults.Items.Add('Completed Forward Navigation Test: ' + IntToStr((e - s) div 1000));
  112.       //  end timer 4
  113.  
  114.       //  backward navigation test
  115.       //  start timer 5
  116.       s := GetTickCount;
  117.       try
  118.         MyRs := MyDB.OpenRecordset('Table1', DAOdbOpenTable, 0);
  119.         MyRs.MoveLast;
  120.         while not MyRs.BOF do
  121.           MyRs.MovePrevious;
  122.         MyRs.Close;
  123.       finally
  124.         if assigned(MyRs) then
  125.           MyRs.Free;
  126.       end;
  127.       e := GetTickCount;
  128.       lstTimeResults.Items.Add('Completed Backward Navigation Test: ' + IntToStr((e - s) div 1000));
  129.       //  end timer 5
  130.  
  131.       //  end timer 1
  132.       eT1 := GetTickCount;
  133.  
  134.       lstTimeResults.Items.Add('Total Time: ' + IntToStr((eT1 - sT1) div 1000));
  135.     finally
  136.       if assigned(MyDb) then
  137.         MyDb.Free;
  138.       if assigned(MyWs) then
  139.         MyWs.Free;
  140.       if assigned(MyEng) then
  141.         MyEng.Free;
  142.     end;
  143.   finally
  144.     btnStart.Enabled := true;
  145.   end;
  146. end;
  147.  
  148. end.
  149.